class Comments1Controller < ApplicationController
  before_filter :authorize  

  def create
    @article = Article.find_by_user_id_and_id(params[:user_id], params[:article_id])
    @comment = Comment.new(:user_id => current_user.id, :body => params[:comment][:body], :aliasn => params[:comment][:aliasn])

    if @article.comments << @comment
      flash[:notice] = 'Comment was successfully created.'

      redirect_to article_path(:user_id => @article.user, :id => @article)
    else
     render :controller => 'articles', :action => 'show', :user_id => @article.user, :id => @article
    end
  end

  def destroy
    @article = Article.find_by_user_id_and_id(current_user.id, params[:article_id], :include => :user)
    @comment = @article.comments.find(params[:id])
    @comment.destroy

    redirect_to article_path(:user_id => @article.user.id, :id => @article.id)
  end
  
    def mytest

			@testobj =Comment.find(params[:id])
			@testobj.ispublished = true
			@testobj.save
		
		end
  def mytest1

		@testobj =Comment.find(params[:id])
		@testobj.ispublished = false
		@testobj.save
	
	end
end
